Skip to content

fix: 修复滞后加载状态覆盖桌面歌词的问题#1074

Open
abkkkbb wants to merge 1 commit into
SPlayer-Dev:devfrom
abkkkbb:codex/fix-desktop-lyric-loading
Open

fix: 修复滞后加载状态覆盖桌面歌词的问题#1074
abkkkbb wants to merge 1 commit into
SPlayer-Dev:devfrom
abkkkbb:codex/fix-desktop-lyric-loading

Conversation

@abkkkbb
Copy link
Copy Markdown

@abkkkbb abkkkbb commented May 14, 2026

修复内容

修复桌面歌词在歌词已经正常加载后,又被滞后的加载状态或空歌词数据覆盖的问题。

这个问题会导致桌面歌词从正常歌词变成“歌词加载中...”或“纯音乐,请欣赏”。

主要改动

  • 切歌进入歌词加载状态时,同步传递当前歌曲 ID 和空歌词数据。

  • 桌面歌词请求数据时,避免把旧歌词和新的加载状态混在一起。

  • 桌面歌词窗口在已有有效歌词时,忽略同一首歌的滞后空歌词加载更新。

  • 已本地复现并验证修复桌面歌词显示问题;同时 fork Actions 构建通过。

image

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request improves desktop lyric synchronization by ensuring more comprehensive data is sent during loading states and implementing logic to prevent UI flickering. Key changes include updating IPC messages in PlayerController and initIpc, and adding a filtering mechanism in the DesktopLyric view to ignore stale loading updates. Feedback suggests aligning the songId type definition in the LyricData interface with the actual data types used and refining the logic for ignoring loading updates to better maintain UI consistency.

window.electron.ipcRenderer.send("desktop-lyric:update-data", {
currentTime: startSeek,
lyricLoading: true,
songId: song.id,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

歌曲 ID (song.id) 在项目中可能是 numberstring 类型(例如在 retryInfo 中定义为 number | string),但 LyricData 接口中将其定义为了 number。建议将 LyricData 接口中的 songId 类型更新为 number | string 以确保类型定义与实际 IPC 通信数据一致。这符合项目信任内部 IPC 数据结构的原则,通过完善类型定义而非增加运行时校验来保证安全。

References
  1. For internal IPC communication, trust the incoming data structure and avoid adding manual, defensive runtime validation for type safety.

Comment on lines +188 to +192
const shouldIgnoreLoadingUpdate = (data: LyricData) => {
if (data.lyricLoading !== true) return false;
if (hasLyricLines(data) || !hasLyricLines(lyricData)) return false;
return data.songId === undefined || data.songId === lyricData.songId;
};
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

在切歌场景下,来自前一首歌曲的滞后“加载中”消息可能覆盖当前歌曲的状态。建议在当前已有歌词的情况下,忽略任何不带歌词数据的加载状态更新。这能有效防止 UI 闪烁并确保数据一致性,符合项目在处理异步更新时优先保证数据一致性和防止视觉闪烁的原则。

const shouldIgnoreLoadingUpdate = (data: LyricData) => {
  if (data.lyricLoading !== true) return false;
  if (hasLyricLines(data) || !hasLyricLines(lyricData)) return false;
  return true;
};
References
  1. When a backend process provides incomplete data in its streaming callbacks, prefer collecting the full dataset and then sending it in chunks to the frontend to ensure data consistency and prevent UI flickering.

@abkkkbb abkkkbb marked this pull request as ready for review May 14, 2026 12:05
Copilot AI review requested due to automatic review settings May 14, 2026 12:06
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR addresses desktop lyric flicker/regression where late loading or empty lyric updates can overwrite already loaded lyrics.

Changes:

  • Adds desktop lyric logic to ignore stale empty loading updates when valid lyrics already exist.
  • Prevents loading placeholder from replacing available lyrics.
  • Sends song ID and empty lyric arrays during lyric-loading hydration/startup states.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
src/views/DesktopLyric/index.vue Adds stale-loading guard and adjusts placeholder rendering.
src/utils/initIpc.ts Avoids mixing loading state with existing lyric data in desktop lyric request responses.
src/core/player/PlayerController.ts Includes song/timing metadata and empty lyric arrays in desktop lyric loading updates.

Comment on lines +720 to 726
if (shouldIgnoreLoadingUpdate(data)) {
if (isInitializing.value) {
isInitializing.value = false;
}
return;
}
Object.assign(lyricData, data);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants